import {Control} from "react-keeper";

require('./PageRegister.less');

import Reflux from 'reflux';
import { Button, Picker, List, InputItem, NavBar } from 'antd-mobile';
import ReactMixin from 'react-mixin';
import Actions from './Actions'
import Store from './Store';
const Item = List.Item;

class Register extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      sValue:[],
      visible: true,
      loadbt: {
        label: '查看更多',
        onClick: this.popbt.bind(this)
      }
    };

    this.changeCertNum = this.changeCertNum.bind(this);
    this.changeCurt = this.changeCurt.bind(this);
    this.changeCurtOK = this.changeCurtOK.bind(this);
    this.enterInfo = this.enterInfo.bind(this);
    this.goHome = this.goHome.bind(this);
    this.getSel = this.getSel.bind(this);
    this.setSelectCour = this.setSelectCour.bind(this);
  }

  setSelectCour(obj) {
    Actions.setCurt(obj);
  }

  getSel() {

  }

  changeCurt(v) {
    this.setState({ sValue: v })
  }

  changeCurtOK(v){
    Actions.changeCurt(v);
  }

  goHome() {
    Control.go('/home/user/my', null);
  }

  changeCertNum(e) {
    Actions.changeCertNum(e);
  }

  enterInfo() {
    /*Actions.checkCertNum();*/
    Actions.enterInfo();
  }

  popbt() {
  }

  render() {

    return (
      <div className="btn-container">
        <NavBar mode="dark">业主绑定</NavBar>
        <List renderHeader={() => '请如实填写身份证信息'}>
          <InputItem
            editable={this.state.reg.info.editable}
            placeholder={this.state.reg.info.certNum}
            onChange={this.changeCertNum}
          >身份证号</InputItem>
          <InputItem
            value={this.state.reg.info.name}
            editable={false}
          >姓名</InputItem>
          <InputItem
            type="phone"
            editable={this.state.reg.info.editable}
            placeholder={this.state.reg.info.tel}
          >手机号码</InputItem>
        </List>
        <Item>
          <div style={{ width: '100%', color: '#108ee9', textAlign: 'right' }}>
            <Button type="primary" size="small" inline onClick={this.enterInfo}>绑定</Button>
          </div>
        </Item>
      </div>
    );
  }

  componentWillMount() {
    // Actions.initMode();
    Actions.initInfo();
  }

  componentDidMount() {
    // Actions.initUser();
  }

  componentWillReceiveProps(nextProps) {

  }

  shouldComponentUpdate(nextProps, nextState) {
    const thisProps = this.props || {},
      thisState = this.state.reg || {};
    if (Object.keys(thisProps).length !== Object.keys(nextProps).length ||
      Object.keys(thisState).length !== Object.keys(nextState).length) {
      return true;
    }

    for (const key in nextProps) {
      if (thisProps[key] !== nextProps[key]) {
        console.log(thisProps[key], nextProps[key]);
        return true;
      }
    }

    for (const key in nextState) {
      if (thisState[key] !== nextState[key]) {
        return true;
      }
    }
    return false;
  }

  componentWillUpdate(nextProps, nextState) {

  }


  componentDidUpdate(prevProps, prevState) {

  }


  componentWillUnmount() {

  }

}

ReactMixin.onClass(Register, Reflux.connect(Store, 'reg'));


export default Register ;
